E. Nordmoe
E. Nordmoe
mtcarsmtcars==> See R4DS for more details!
Step 1: Create the Function
Step 2: Apply the function by looping
col_mean() and
col_median() functions.mtcarsmap() ==> listmap_lgl() ==> logical vectormap_dbl() ==> double vectormtcarsmap_df to create a data frame by binding rowsmap2()pmap()fun <- function(f) pmap(list(x = mtcars, na.rm = TRUE), f)
param <- list(list(mean), list(median), list(sd))
#was
invoke_map(.f = fun, .x = param)
#now
map(param, fun)invoke_map() level, fun takes as
arguments param, which are the functions we want to apply
to mtcars.fun level, these functions stored in
param are applied by pmap(), one at a time, to
each column in mtcars.